//
//  UIViewEx.m
//  mcf
//
//  Created by yuike6 yuike6 on 12-1-7.
//  Copyright (c) 2012年 yuike. All rights reserved.
//

#import "UIViewEx.h"
#import "header.h"

@implementation UIViewEx
@synthesize currrentInterfaceOrientation = _currrentInterfaceOrientation;
@synthesize disabled;
@synthesize bInited;

@synthesize width = width__;
@synthesize height = height__;
@synthesize origin_x = origin_x_;
@synthesize origin_y = origin_y_;

-(float) width
{
    return VIEW_WIDTH;
}

-(float) height
{
    return VIEW_HEIGHT;
}

-(float) origin_x
{
    return self.frame.origin.x;
}

-(float) origin_y
{
    return self.frame.origin.y;
}


- (void) setDisabled:(BOOL) value {
	disabled = value;
	if(value)
    {
        [self disableGesture];
    }
    else
    {
        [self enableGesture];
    }	
}

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) 
    {
        // Initialization code
        currrentInterfaceOrientation = [[UIApplication sharedApplication] statusBarOrientation];
    }
    return self;
}


-(void)rotate:(UIInterfaceOrientation)interfaceOrientation includeSubViews:(BOOL) bIncluded
    animation:(BOOL)animation{
    @autoreleasepool 
    {
        currrentInterfaceOrientation = interfaceOrientation;        
        if (animation) 
        {
            //UIViewAnimationOptionAllowUserInteraction
            [[YkAnimationStep for:0.4 animate:^{
                [self reAdjustLayout];  
            }] runAnimation]  ; // run
            
        }
        else
        {
            [self reAdjustLayout];
        }
        
        if (bIncluded) 
        {
            for (UIView * subView in self.subviews) 
            {
                if ([subView isKindOfClass:[UIViewEx class]]) 
                {
                    [(UIViewEx *)subView rotate:interfaceOrientation includeSubViews:bIncluded animation:animation];
                }
            }
        } 
    }	  
}


-(void)reAdjustLayout {
	//kMustOverrideMethod
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/
-(void) destory
{
    
}

-(void) setFrame:(CGRect)frame
{
    frame.origin.x = (int) (frame.origin.x + 0.5f);
    frame.origin.y = (int) (frame.origin.y + 0.5f);
    frame.size.width = (int) (frame.size.width + 0.5f);
    frame.size.height = (int) (frame.size.height + 0.5f);
    [super setFrame:frame];
}

@end
